function focusout_optionbox(){
        
        var cmtID;
        $(document).click(function(e){
            var id = '';
            id=$(e.target).attr('id');
            //var id1=$(e.target).parent().attr('id');

            id == null ? id = '' : id ;
//            console.log("id--"+id);
//            console.log(id.indexOf('option_cmt_'));
            if(id.indexOf('option_cmt_') == 0 ){
                cmtID = id.replace('option_cmt_','');
                
            }
            if(id.indexOf('option') == -1)
            {               
//              console.log(cmtID+"--cmtID--"+$('.option_cmt_box').css('display'));
                if($('#option_cmt_box_'+cmtID).css('display') == 'block'){
                    $('#option_cmt_box_'+cmtID).css('display','none');
                }
            }
        });
        
    }
    focusout_optionbox();
    function append_comment(id){
        var objID = id;
        var cmtID;
        var act;
        var cmt_content;
        if(objID.indexOf('option') != -1){
            cmtID = objID.replace('option_cmt_','');
        }

        if(objID.indexOf('edit')!= -1){
            cmtID = objID.replace('cmt_','');
            cmtID = cmtID.replace('_edit','');

        }
        if(objID.indexOf('delete')!= -1){
            cmtID = objID.replace('cmt_','');
            cmtID = cmtID.replace('_delete','');

        }
        if(objID.indexOf('submit')!= -1){
            cmtID = objID.replace('cmt_','');
            cmtID = cmtID.replace('_submit','');

        }

        switch(objID){
            case 'option_cmt_'+cmtID :
                                    $('#option_cmt_box_'+cmtID).toggle(100);
                                    break;
            case 'cmt_'+cmtID+'_edit': 
                                        cmt_content = $('#cmt_content_'+cmtID).text();
                                        $('#cmt_content_'+cmtID).remove();
                                        var html = '<textarea name="cmt_content_'+cmtID+'" cols="50" rows="2" ' 
                                                +' class="comment_detail" style="padding:0px;margin: 0px;width :435px ;height: 55px ; border-color: #F29F00; text-align: justify;"'
                                                +'id="cmt_content_'+cmtID+'"'
                                                +'/>';
                                            $('#cmt_content_box_'+cmtID).append(html);
                                            $('#cmt_content_'+cmtID).attr('value',cmt_content);
                                            $('#option_cmt_box_'+cmtID).toggle(100);
                                            $('#option_cmt_'+cmtID).attr('id','cmt_'+cmtID+'_submit');
                                            $('#cmt_'+cmtID+'_submit').html('Xong');


                                    break;
            case 'cmt_'+cmtID+'_delete':
                                        $('#cmt_box_'+cmtID).remove();
                                        act= 0;
                                        $.ajax({
                                            url: base_url+"adlab/option_cmt",
                                            type : "post",
                                            data :{
                                                cmtID_post : cmtID,
                                                act_post : act                                                        
                                            }
                                        });
                                    break;
            case 'cmt_'+cmtID+'_submit': cmt_content = $('#cmt_content_'+cmtID).val();                                        
                                        act = 1;
                                        $.ajax({
                                        url: base_url+"adlab/option_cmt",
                                        type : "post",
                                        data :{
                                            cmtID_post : cmtID,
                                            act_post : act,
                                            cmt_content_post : cmt_content

                                        },
                                        success :function (data){
                                            if(data.error){
                                                alert('Có lỗi xảy ra, vui lòng thử lại');
                                            }
                                            else{

                                                $('#cmt_'+cmtID+'_submit').attr('id','option_cmt_'+cmtID);
                                                $('#option_cmt_'+cmtID).html('Tùy chọn');
                                                $('#cmt_content_'+cmtID).remove();
                                                var html = '<p style="padding:0px;margin: 0px; text-align: justify;"' 
                                                            + 'id="cmt_content_'+cmtID+'">'
                                                            + cmt_content
                                                            +'</p>' ;
                                                $('#cmt_content_box_'+cmtID).append(html);

                                            }
                                        }
                                        });
                                        break;
        }        
    }